﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TGInspect
{
    [Flags]
    public enum OutNum
    {
        Aligner=0,
        AlignerBwd,
        Aligner1=16,
        Aligner1Bwd,
        Adjust1=32,
        
    }

    public class Output : IUpdate
    {
        const int ModPerNum = 16;
        public int[] OutputBuf;
        int ModNum;

        public Output(int modNum)
        {
            this.ModNum = modNum;
            OutputBuf = new int[this.ModNum];
        }


        public bool Get(OutNum outNum)
        {
            int bufNum = (int)outNum / ModPerNum;
            int loc = (int)outNum % ModPerNum;

            if (bufNum >= ModNum) if (bufNum >= ModNum) { throw new Exception("Output bufNum >= ModNum !!"); }
            if ((OutputBuf[bufNum] & (0x1 << loc)) != 0)
                return true;
            else
                return false;
        }
        
        public void Set(bool on, OutNum outNum)
        {
            int bufNum = (int)outNum / ModPerNum;
            int loc = (int)outNum % ModPerNum;
            
            if (bufNum >= ModNum) return;
            if(on)
                OutputBuf[bufNum] |= (0x1 << loc);
            else
                OutputBuf[bufNum] &= ~(0x1 << loc);
        }
        
        public void Update()
        {

        }
    }
}
